package Zoo.handler;


import Zoo.view.leaderview.AddZooparkView;
import Zoo.view.leaderview.DeleteZooparkView;
import Zoo.view.leaderview.LeaderView;
import Zoo.view.leaderview.UpdateZooparkView;


import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 园长所看到的园区主界面的增删改查功能
 */
public class LeaderViewHandler implements ActionListener {
    private LeaderView leaderView;


    public LeaderViewHandler(LeaderView leaderView) {
        this.leaderView = leaderView;
    }


    @Override
    public void actionPerformed(ActionEvent e) {
        JButton jButton = (JButton) e.getSource();
        String text = jButton.getText();
        if ("增加".equals(text)) {
            new AddZooparkView(leaderView);
        } else if ("修改".equals(text)) {
            new UpdateZooparkView(leaderView);
        } else if ("删除".equals(text)) {
            new DeleteZooparkView(leaderView);
        } else if ("查询".equals(text)) {
            leaderView.reloadTable();

        }
    }

}
